<template>
  <!-- 指令下发弹框 开关机控制 -->
  <el-dialog v-model="dialogShow2" width="30%">
    <div class="titleShow">
      <div class="titles">{{ $t('licence.sys_switch') }}</div>
    </div>
    <el-radio style="display: block; margin-bottom: 20px" v-model="open" label="1">
      {{ $t('licence.sys_kai') }}</el-radio>
    <el-radio style="display: block; margin-bottom: 20px" v-model="open" label="2">
      {{ $t('licence.sys_guan') }}</el-radio>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogShow2 = false">{{ $t('licence.cancel') }}</el-button>
        <el-button type="primary" @click="instruction">{{ $t('licence.determine') }}</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { commandControl } from "@/api/inveter/inveter";
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const dialogShow2 = ref(false) //开关机控制
const open = ref('1') //开关机控制
const props = defineProps(['ids','lang','powerStation']);
const instruction = async ()=>{
  ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
      confirmButtonText: t("licence.determine"),
      cancelButtonText: t("licence.cancel"),
      type: "warning",
    })
      .then(async () => {
        let data = {
          commandId: 2,
          ids: props.ids.join(","),
          type: open.value,
          lang: props.lang,
        };
        await commandControl(data);
        ElMessage({
          type: "success",
          message: t("licence.success"),
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: t("licence.cancels"),
        });
      });
    dialogShow2.value = false;
}
const openDialog = () => {
  dialogShow2.value = true;
  open.value = "1"; //开关机控制
}
defineExpose({
  openDialog
})
</script>